<template>
  <div class="app-container">
    <el-card class="filter-container" shadow="never">
      <div>
        <i class="el-icon-search"></i>
        <span>筛选搜索</span>
        <el-button
          style="float:right"
          type="primary"
          @click="handleSearchList()"
          size="small">
          查询搜索
        </el-button>
        <el-button
          style="float:right;margin-right: 15px"
          @click="handleResetSearch()"
          size="small">
          重置
        </el-button>
      </div>
      <div style="margin-top: 15px">
        <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
          <el-form-item label="手机号：">
            <el-input v-model="listQuery.username" class="input-width" placeholder="手机号" clearable></el-input>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
    <el-card class="operate-container" shadow="never">
      <i class="el-icon-tickets"></i>
      <span>数据列表</span>
    </el-card>
    <div class="table-container">
      <el-table
        ref="adminTable"
        :data="list"
        style="width: 100%;"
        v-loading="listLoading"
        border>
        <el-table-column label="手机号" align="center">
          <template slot-scope="scope">{{ scope.row.phone }}</template>
        </el-table-column>
        <el-table-column label="提交时间" align="center">
          <template slot-scope="scope">{{ scope.row.createTime | formatDateTime }}</template>
        </el-table-column>
        <el-table-column label="状态" align="center">
          <template slot-scope="scope">{{ status[scope.row.status] }}</template>
        </el-table-column>
        <el-table-column label="审核通过时间" align="center" >
          <template slot-scope="scope" v-if="scope.row.status=='02'">{{ scope.row.updateTime | formatDateTime }}</template>
        </el-table-column>
        <el-table-column label="审核不通过时间" align="center">
          <template slot-scope="scope" v-if="scope.row.status=='03'">{{ scope.row.updateTime | formatDateTime }}</template>
        </el-table-column>
        <el-table-column label="操作" width="180" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="handleDetails(scope.$index, scope.row)"
              v-if="scope.row.status!=='01'">
              查看
            </el-button>
            <el-button
              size="mini"
              type="text"
              @click="handleAud(scope.$index, scope.row)"
              v-if="scope.row.status=='01'">
              审核
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pagination-container">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total, sizes,prev, pager, next,jumper"
        :current-page.sync="listQuery.pageNum"
        :page-size="listQuery.pageSize"
        :page-sizes="[10,15,20]"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { fetchMemberList, updateMemberAdmin } from '@/api/login'
import { getMenberById, auditList } from '@/api/memberLevel'
// import { province } from '@/api/servDept'
import { formatDate } from '@/utils/date'
import SingleAddress from '@/components/SingleAddress'
const defaultListQuery = {
  pageNum: 1,
  pageSize: 10,
  username: null
}
const defaultAdmin = {
  'username': null,
  'password': null,
  'city': null,
  'id': 0,
  'memberLevelId': 0,
  'phone': '',
  'idCard': '',
  'communityName': '',
  'name': '',
  'nickname': ''
}
export default {

  data () {
    return {
      params: {},
      status: {
        '01': '待审核',
        '02': '审核通过',
        '03': '审核不通过'
      },
      list1: {},
      options: [{
        value: '1',
        label: '男'
      }, {
        value: '2',
        label: '女'
      }],
      value: '男',
      adress: [],
      optionsAdress: [],
      props: {
        value: 'code',
        label: 'name',
        children: 'cities'
      },
      listQuery: Object.assign({}, defaultListQuery),
      list: null,
      total: null,
      listLoading: false,
      // dialogVisible: false,
      admin: Object.assign({}, defaultAdmin),
      isEdit: false,
      rules: {
        newpwd: [
          { required: true, message: '请输入密码', trigger: 'blur' }
        ]
      }
    }
  },
  components: { SingleAddress },
  created () {
    this.getList()
    // this.getProvice()
  },
  mounted () {

  },
  filters: {
    formatDateTime (time) {
      if (time == null || time === '') {
        return 'N/A'
      }
      const date = new Date(time)
      return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
    }
  },
  methods: {
    handleChange (val) {
      this.admin.province = val[0]
      this.admin.city = val[1]
      // console.log(8,val);
    },
    handleAud (index, row) {
      this.$router.push({ path: '/user-ms/AudUser', query: { id: row.id, userId: row.userId } })
    },
    handleDetails (index, row) {
      this.$router.push({ path: '/user-ms/audDetails', query: { id: row.id, userId: row.userId } })
    },
    handleResetSearch () {
      this.listQuery = Object.assign({}, defaultListQuery)
    },
    handleSearchList () {
      this.listQuery.pageNum = 1
      this.getList()
      console.log(this.listQuery)
    },
    handleSizeChange (val) {
      this.listQuery.pageNum = 1
      this.listQuery.pageSize = val
      this.getList()
    },
    handleCurrentChange (val) {
      this.listQuery.pageNum = val
      this.getList()
    },
    getList () {
      this.listLoading = true
      auditList(this.listQuery).then(response => {
        this.listLoading = false
        this.list = response.data.list
        this.total = response.data.total
      })
    }
  }
}
</script>
<style>
  .button{
    float:right;
    right:0;
  }
</style>
